<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/common/base.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Insert title here</title>
<script type="text/javascript">
	
	var ligergrid = null;
	
    $(function ()
    {
        ligergrid = $("#maingrid").ligerGrid({
            columns: [
              { display: '年度名称', name: 'name', width:'15%'},
              { display: '统计开始时间', name: 'startTime', width:'15%'},
              { display: '统计结束时间', name: 'endTime', width:'15%'},
              { display: '版本类型', name: 'rptAttribute',width:'10%',render:function(row){
				  var rptAttributeMap = {'1':'半年报','2':'全年报'};
            	  return rptAttributeMap[row.rptAttribute + ''];
              }},
              { display: '年度具体说明', name: 'description', width:'30%'},
              {
                  display: '操作', isAllowHide: false,width:'15%',
                  render: function (row)
                  {
                	  var myDate = new Date();
                	  var myYear = myDate.getFullYear();
                      var html = '';
                    	  html += '<a href="#" onclick="annualUpdate(\'' + row.annualId + '\')" class="update-btn">编辑</a>||';
                    	  html += '<a href="#" onclick="deleteAnnual(\'' + row.annualId + '\')" class="update-btn">删除</a>||';
                    	  html += '<a href="#" onclick="annualDetail(\'' + row.annualId + '\')" class="update-btn">明细</a>';
                      return String.format(html,row.annualId);
                  }
              }

            ],
            url: '${ctx}/rptAnnualController/tableData',
            pageSize: 10, sortName: 'orderId',
            width: '99%', height: '96%', rownumbers:true,
            pageParmName:'pageNum',
            pagesizeParmName:'pageSize',
            sortnameParmName:'sortname',
            sortorderParmName:'sortorder',
            alternatingRow:true,
        });
    });
    
    function onNewWin(){
		$.layer({
		    type: 2,
		    maxmin: true,
		    shadeClose: true,
		    title: '新增报表版本',
		    shade: [0.1,'#000000'],
		    shift:'top',
		    offset: [($(window).height() / 20)+'px',''],
		    area: ['800px', '400px'],
		    iframe: {src: '${ctx}/rptAnnualController/preCreate'}
		}); 
	}
    function annualUpdate(annualId){
		$.layer({
		    type: 2,
		    maxmin: true,
		    shadeClose: true,
		    title: '报表版本修改',
		    shade: [0.1,'#000000'],
		    shift:'top',
		    offset: [($(window).height() / 20)+'px',''],
		    area: ['800px', '400px'],
		    iframe: {src: '${ctx}/rptAnnualController/preUpdate/'+annualId}
		}); 
		//$.ligerDialog.open({ url: '${ctx}/userAction/preCreate', width: 800,height:350,modal:true,title:'新增人员信息'});
	}
    function annualDetail(annualId){
		$.layer({
		    type: 2,
		    maxmin: true,
		    shadeClose: true,
		    title: '报表版本明细',
		    shade: [0.1,'#000000'],
		    shift:'top',
		    offset: [($(window).height() / 20)+'px',''],
		    area: ['800px', '400px'],
		    iframe: {src: '${ctx}/rptAnnualController/detail/'+annualId}
		}); 
		//$.ligerDialog.open({ url: '${ctx}/userAction/preCreate', width: 800,height:350,modal:true,title:'新增人员信息'});
	}
    function deleteAnnual(annualId){
		layer.confirm('是否删除',function(){
			$.ajax({
				url:'${ctx}/rptAnnualController/deleteAnnual/'+annualId,
				type:'POST',
				cache:false,
				success:function(data){
					if(data == 'success'){
						layer.alert('操作成功',9);
						//$.ligerDialog.success('操作成功');
						location.reload();
					}else{
						layer.alert('操作失败');
						//$.ligerDialog.error('操作失败');
					}
				}
			});
		});
	}
    function f_query(){
		ligergrid.set('parms',$('#form1').serializeArray());
		ligergrid.loadData();
	}
    //清空所有查询条件
    function textEmpty(){
    	$("#name").val("");
    }
</script>
</head>
<body>
<div style="margin-right:15px;margin-top:5px;padding:5px;border:0px solid green;position:relative;">
	<form name="form1" method="get"  id="form1" class="form-horizontal">
			<div class="control-group">
				<div class="controls">
					<div class="controls">
						<label class="control-label" for="report_type">年度名称：</label>
						<input id="name" name="filter_LIKES_name" type="text" class="input-medium" value="${param['filter_LIKES_name']}" />
						<input type="button" class="btn btn-info" value="查询" onclick="f_query();" />
						<button class="btn btn-info" onclick="textEmpty();">
							清空</button>
						<input type="button" class="btn btn-info" value="新增版本" onclick="onNewWin();" />
					</div>
				</div>
			</div>
	</form>
</div>
	<div id="maingrid" style="margin:5px; padding:0;height:90%"></div>
	<div style="display:none;"></div>
</body>
</html>